package body IO_Utils is

   ----------------------
   -- Read_File_Stream --
   ----------------------

   procedure Read_File_Stream
     (Filename : String;
      Process   : not null access procedure (FS : not null access Stream_Class))
   is
      F : Stream_IO.File_Type;
   begin
      Stream_IO.Open (File => F, Name => Filename, Mode => Stream_IO.In_File);
      begin
         Process (Stream_IO.Stream (F));
      exception
         when others =>
            Stream_IO.Close (F);
            raise;
      end;
      Stream_IO.Close (F);
   end Read_File_Stream;

   ---------------
   -- Read_File --
   ---------------

   procedure Read_File
     (Filename : String;
      Process   : not null access procedure (F : in out Stream_IO.File_Type))
   is
      F : Stream_IO.File_Type;
   begin
      Stream_IO.Open (File => F, Name => Filename, Mode => Stream_IO.In_File);
      begin
         Process (F);
      exception
         when others =>
            Stream_IO.Close (F);
            raise;
      end;
      Stream_IO.Close (F);
   end Read_File;

end IO_Utils;
